{% extends "./layout.html" %}

{% block head %}
    {{ super() }}
    {% if progress.current.next and progress.current.next.path %}
    <link rel="next" href="{{ basePath }}/{{ progress.current.next.path|contentLink }}" />
    {% endif %}
    {% if progress.current.prev and progress.current.prev.path %}
    <link rel="prev" href="{{ basePath }}/{{ progress.current.prev.path|contentLink }}" />
    {% endif %}
{% endblock %}

{% block title %}{{ progress.current.title }} | {{ title }}{% endblock %}
{% block description %}{% if progress.current.level == "0" %}{{ description }}{% endif %}{% endblock %}

{% block content %}
    <div class="book"
        data-level="{{ progress.current.level }}"
        data-chapter-title="{{ progress.current.title }}"
        data-filepath="{{ progress.current.path }}"
        data-basepath="{{ basePath }}"
        data-revision="{{ revision }}"
        data-innerlanguage="{{ innerlanguage }}">
    {% include "includes/summary.html" %}
    <div class="book-body">
        <div class="body-inner">
            {% include "includes/header.html" %}
            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                {% block page_inner %}
                {% for section in content %}
                    <section class="{{ section.type }}" id="section-{{ section.id }}">
                    {% if section.type == "normal" %}
                        {% autoescape false %}{{ section.content }}{% endautoescape %}
                    {% endif %}
                    </section>
                {% endfor %}
                {% endblock %}
                </div>
            </div>
        </div>

        {% if progress.current.prev and progress.current.prev.path %}
        <a href="{{ basePath }}/{{ progress.current.prev.path|contentLink }}" class="navigation navigation-prev {% if not (progress.current.next and progress.current.next.path) %}navigation-unique{% endif %}" aria-label="Previous page: {{ progress.current.prev.title }}"><i class="fa fa-angle-left"></i></a>
        {% endif %}
        {% if progress.current.next and progress.current.next.path %}
        <a href="{{ basePath }}/{{ progress.current.next.path|contentLink }}" class="navigation navigation-next {% if not (progress.current.prev or progress.current.prev.path) %}navigation-unique{% endif %}" aria-label="Next page: {{ progress.current.next.title }}"><i class="fa fa-angle-right"></i></a>
        {% endif %}
    </div>
</div>
{% endblock %}

{% block javascript %}
<script src="{{ staticBase }}/app.js"></script>
{% for resource in plugins.resources.js %}
    {% if resource.url %}
    <script src="{{ resource.url }}"></script>
    {% else %}
    <script src="{{ staticBase }}/plugins/{{ resource.path }}"></script>
    {% endif %}
{% endfor %}
<script>
require(["gitbook"], function(gitbook) {
    var config = {% autoescape false %}{{ pluginsConfig }}{% endautoescape %};
    gitbook.start(config);
});
</script>
{% endblock %}

{% block style %}
    <link rel="stylesheet" href="{{ staticBase }}/style.css">
    {% for resource in plugins.resources.css %}
        {% if resource.url %}
        <link rel="stylesheet" href="{{ resource.url }}">
        {% else %}
        <link rel="stylesheet" href="{{ staticBase }}/plugins/{{ resource.path }}">
        {% endif %}
    {% endfor %}
    {% for type, style in styles %}
        <link rel="stylesheet" href="{{ basePath }}/{{ style }}">
    {% endfor %}
{% endblock %}
